// 获取对象数组
let spans = document.getElementById("box").getElementsByTagName("span");
console.log(spans);

// 设置时间函数
let setDate = ()=>{
    let nowDate = new Date();
    let year = nowDate.getFullYear();
    let month = nowDate.getMonth()+1;
    let day = nowDate.getDate();
    let hour = nowDate.getHours();
    let minute = nowDate.getMinutes();
    let second = nowDate.getSeconds(); 

    spans[0].innerHTML = year;
    spans[1].innerHTML = month;
    spans[2].innerHTML = day;
    spans[3].innerHTML = hour;
    spans[4].innerHTML = minute;
    spans[5].innerHTML = second;
}

// 调用设置事件
setDate();

// 自动刷新
window.onload = ()=>{
    setInterval(setDate,1000);
}